package com.xiaoma.myaudience.biz.model;

import org.json.JSONException;
import org.json.JSONObject;

import android.os.Parcel;
import android.os.Parcelable;

public class SearchResultInfo extends BaseVideoInfo {
	
    /**视频ID*/
    public static final String PARAM_PID = "pid";
    /**视频简介*/
    public static final String PARAM_DIGEST = "digest";
    /**视频上映年份*/
    public static final String PARAM_LAUNCH = "launch";
    /**视频主演*/
    public static final String PARAM_PERFORMER = "performer";
    /**导演*/
    public static final String PARAM_DIRECTOR = "director";
    /**视频类型*/
    public static final String PARAM_VTYPE = "vtype";
    
    public String mPid;
    public String mDigest;
    public String mLaunch;
    public String mPerformer;
    public String mDirector;
    public String mType;
    
    /***
     * 从JSONObject中读取到Info中
     */
    @Override
    public void readFromJSONObject(JSONObject o) throws JSONException{
        super.readFromJSONObject(o);
        if (o != null) {
        	if(o.has(PARAM_DIGEST)) mDigest = o.getString(PARAM_DIGEST);
        	if(o.has(PARAM_LAUNCH)) mLaunch = o.getString(PARAM_LAUNCH);
        	if(o.has(PARAM_PERFORMER)) mPerformer = o.getString(PARAM_PERFORMER);
        	if(o.has(PARAM_PID)) mPid = o.getString(PARAM_PID);
        	if(o.has(PARAM_DIRECTOR)) mDirector = o.getString(PARAM_DIRECTOR);
        	if(o.has(PARAM_VTYPE)) mType = o.getString(PARAM_VTYPE);
        }
    }

    @Override
    public void writeToParcel(Parcel parcel, int paramInt) {
        super.writeToParcel(parcel, paramInt);
        parcel.writeString(mPid);
        parcel.writeString(mDigest);
        parcel.writeString(mLaunch);
        parcel.writeString(mPerformer);
        parcel.writeString(mDirector);
        parcel.writeString(mType);
    }  
    
    @Override
    public void readFromParcel(Parcel source) {
        super.readFromParcel(source);
        mPid = source.readString();
        mDigest = source.readString();
        mLaunch = source.readString();
        mPerformer = source.readString();
        mDirector = source.readString();
        mType = source.readString();
    }

    public static final Parcelable.Creator<SearchResultInfo> CREATOR = new Creator<SearchResultInfo>() {
        public SearchResultInfo createFromParcel(Parcel source) {
        	SearchResultInfo info = new SearchResultInfo();
            info.readFromParcel(source);
            return info;
        }

        public SearchResultInfo[] newArray(int size) {
            return new SearchResultInfo[size];
        }
    };
    
}
